//
// $Id$

package zachg.survival;

import java.awt.Point;

import javax.swing.JComponent;

import zachg.survival.GameCharacterSprite;
import zachg.survival.SurvivalBoardView;
import zachg.survival.SurvivalObject;

import com.threerings.media.util.LinePath;
import com.threerings.toybox.util.GameViewTest;
import com.threerings.toybox.util.ToyBoxContext;


/**
 * A test harness for our board view.
 * 
 * NOTE: NOT USED in any detail after building out game, no idea if this works.
 * 
 */
@SuppressWarnings("serial")
public class SurvivalBoardViewTest extends GameViewTest
{
    public static void main (String[] args)
    {
        SurvivalBoardViewTest test = new SurvivalBoardViewTest();
        test.display();
    }

    protected JComponent createInterface (ToyBoxContext ctx)
    {
        return _view = new SurvivalBoardView(ctx, new SurvivalController());
    }

    protected void initInterface ()
    {
        // add a couple of pieces to the view
        SurvivalObject.GameCharacter gameCharacter = new SurvivalObject.GameCharacter();
        gameCharacter.ownerType = SurvivalObject.PLAYER_ID;
        gameCharacter.x = 1;
        gameCharacter.y = 2;
        _view.addSprite(new GameCharacterSprite(gameCharacter) );
    
        gameCharacter= new SurvivalObject.GameCharacter();
        gameCharacter.ownerType = SurvivalObject.PLAYER_ID;
        gameCharacter.x = 2;
        gameCharacter.y = 2;
        _view.addSprite(new GameCharacterSprite(gameCharacter) );

        gameCharacter= new SurvivalObject.GameCharacter();
        gameCharacter.ownerType = SurvivalObject.ENEMY_ID;
        gameCharacter.x = 2;
        gameCharacter.y = 2;
        
        
        //Dirty hack to get view test harness to render everything at the start
        _view.getSpriteManager().getRegionManager().invalidateRegion(0, 0, _view.getSize().width, _view.getSize().height);
        
        GameCharacterSprite sprite = new GameCharacterSprite(gameCharacter);
        _view.addSprite(sprite);
        int dx = gameCharacter.x * GameCharacterSprite.SIZE;
        int dy = (gameCharacter.y+20) * GameCharacterSprite.SIZE;
        sprite.move(new LinePath(new Point(dx, dy), 1000L));
        
        _view.setPlacingMode(SurvivalObject.PLAYER_ID);
        
    }
    
    protected SurvivalBoardView _view;
}
